// Copyright (c) 2022-present, Shanghai Yunxi Technology Co, Ltd.
//
// This software (KWDB) is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

#pragma once

/* autogenerated from src/backend/utils/errcodes.txt, do not edit */
#define PGSIXBIT(ch) (((ch) - '0') & 0x3F)
#define PGUNSIXBIT(val) (((val) & 0x3F) + '0')

#define UNPACK_SQLSTATE(sql_state, buf) \
  {                                     \
    int i;                              \
    for (i = 0; i < 5; i++) {           \
        buf[i] = PGUNSIXBIT(sql_state); \
        sql_state >>= 6;                \
    }                                   \
    buf[i] = '\0';                      \
  }

#define MAKE_SQLSTATE(ch1, ch2, ch3, ch4, ch5)                    \
  (PGSIXBIT(ch1) + (PGSIXBIT(ch2) << 6) + (PGSIXBIT(ch3) << 12) + \
  (PGSIXBIT(ch4) << 18) + (PGSIXBIT(ch5) << 24))

/* Class 00 - Successful Completion
 */
#define ERRCODE_SUCCESSFUL_COMPLETION MAKE_SQLSTATE('0', '0', '0', '0', '0')

/* Class 01 - Warning
 */
#define ERRCODE_WARNING MAKE_SQLSTATE('0', '1', '0', '0', '0')
#define ERRCODE_WARNING_DYNAMIC_RESULT_SETS_RETURNED \
  MAKE_SQLSTATE('0', '1', '0', '0', 'C')
#define ERRCODE_WARNING_IMPLICIT_ZERO_BIT_PADDING \
  MAKE_SQLSTATE('0', '1', '0', '0', '8')
#define ERRCODE_WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION \
  MAKE_SQLSTATE('0', '1', '0', '0', '3')
#define ERRCODE_WARNING_PRIVILEGE_NOT_GRANTED \
  MAKE_SQLSTATE('0', '1', '0', '0', '7')
#define ERRCODE_WARNING_PRIVILEGE_NOT_REVOKED \
  MAKE_SQLSTATE('0', '1', '0', '0', '6')
#define ERRCODE_WARNING_STRING_DATA_RIGHT_TRUNCATION \
  MAKE_SQLSTATE('0', '1', '0', '0', '4')
#define ERRCODE_WARNING_DEPRECATED_FEATURE \
  MAKE_SQLSTATE('0', '1', 'P', '0', '1')

/* Class 02 - No Data (this is also a warning class per the SQL standard)
 */
#define ERRCODE_NO_DATA MAKE_SQLSTATE('0', '2', '0', '0', '0')
#define ERRCODE_NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED \
  MAKE_SQLSTATE('0', '2', '0', '0', '1')
#define ERRCODE_INVALID_OPTION MAKE_SQLSTATE('0', '2', '0', '0', '2')

/* Class 03 - SQL Statement Not Yet Complete
 */
#define ERRCODE_SQL_STATEMENT_NOT_YET_COMPLETE \
  MAKE_SQLSTATE('0', '3', '0', '0', '0')

/* Class 08 - Connection Exception
 */
#define ERRCODE_CONNECTION_EXCEPTION MAKE_SQLSTATE('0', '8', '0', '0', '0')
#define ERRCODE_CONNECTION_DOES_NOT_EXIST MAKE_SQLSTATE('0', '8', '0', '0', '3')
#define ERRCODE_CONNECTION_FAILURE MAKE_SQLSTATE('0', '8', '0', '0', '6')
#define ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION \
  MAKE_SQLSTATE('0', '8', '0', '0', '1')
#define ERRCODE_SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION \
  MAKE_SQLSTATE('0', '8', '0', '0', '4')
#define ERRCODE_TRANSACTION_RESOLUTION_UNKNOWN \
  MAKE_SQLSTATE('0', '8', '0', '0', '7')
#define ERRCODE_PROTOCOL_VIOLATION MAKE_SQLSTATE('0', '8', 'P', '0', '1')

/* Class 09 - Triggered Action Exception
 */
#define ERRCODE_TRIGGERED_ACTION_EXCEPTION \
  MAKE_SQLSTATE('0', '9', '0', '0', '0')

/* Class 0A - Feature Not Supported
 */
#define ERRCODE_FEATURE_NOT_SUPPORTED MAKE_SQLSTATE('0', 'A', '0', '0', '0')
#define ERRCODE_STREAM_NOT_SUPPORTED MAKE_SQLSTATE('0', 'A', '1', '0', '0')

/* Class 0B - Invalid Transaction Initiation
 */
#define ERRCODE_INVALID_TRANSACTION_INITIATION \
  MAKE_SQLSTATE('0', 'B', '0', '0', '0')

/* Class 0F - Locator Exception
 */
#define ERRCODE_LOCATOR_EXCEPTION MAKE_SQLSTATE('0', 'F', '0', '0', '0')
#define ERRCODE_L_E_INVALID_SPECIFICATION MAKE_SQLSTATE('0', 'F', '0', '0', '1')

/* Class 0L - Invalid Grantor
 */
#define ERRCODE_INVALID_GRANTOR MAKE_SQLSTATE('0', 'L', '0', '0', '0')
#define ERRCODE_INVALID_GRANT_OPERATION MAKE_SQLSTATE('0', 'L', 'P', '0', '1')

/* Class 0P - Invalid Role Specification
 */
#define ERRCODE_INVALID_ROLE_SPECIFICATION \
  MAKE_SQLSTATE('0', 'P', '0', '0', '0')

/* Class 0Z - Diagnostics Exception
 */
#define ERRCODE_DIAGNOSTICS_EXCEPTION MAKE_SQLSTATE('0', 'Z', '0', '0', '0')
#define ERRCODE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER \
  MAKE_SQLSTATE('0', 'Z', '0', '0', '2')

/* Class 20 - Case Not Found
 */
#define ERRCODE_CASE_NOT_FOUND MAKE_SQLSTATE('2', '0', '0', '0', '0')

/* Class 21 - Cardinality Violation
 */
#define ERRCODE_CARDINALITY_VIOLATION MAKE_SQLSTATE('2', '1', '0', '0', '0')

/* Class 22 - Data Exception
 */
#define ERRCODE_DATA_EXCEPTION MAKE_SQLSTATE('2', '2', '0', '0', '0')
#define ERRCODE_ARRAY_ELEMENT_ERROR MAKE_SQLSTATE('2', '2', '0', '0', 'E')
#define ERRCODE_ARRAY_SUBSCRIPT_ERROR MAKE_SQLSTATE('2', '2', '0', '2', 'E')
#define ERRCODE_CHARACTER_NOT_IN_REPERTOIRE \
  MAKE_SQLSTATE('2', '2', '0', '2', '1')
#define ERRCODE_DATETIME_FIELD_OVERFLOW MAKE_SQLSTATE('2', '2', '0', '0', '8')
#define ERRCODE_DATETIME_VALUE_OUT_OF_RANGE \
  MAKE_SQLSTATE('2', '2', '0', '2', '0')
#define ERRCODE_DIVISION_BY_ZERO MAKE_SQLSTATE('2', '2', '0', '1', '2')
#define ERRCODE_ERROR_IN_ASSIGNMENT MAKE_SQLSTATE('2', '2', '0', '0', '5')
#define ERRCODE_ESCAPE_CHARACTER_CONFLICT MAKE_SQLSTATE('2', '2', '0', '0', 'B')
#define ERRCODE_INDICATOR_OVERFLOW MAKE_SQLSTATE('2', '2', '0', '2', '2')
#define ERRCODE_INTERVAL_FIELD_OVERFLOW MAKE_SQLSTATE('2', '2', '0', '1', '5')
#define ERRCODE_INVALID_ARGUMENT_FOR_LOG MAKE_SQLSTATE('2', '2', '0', '1', 'E')
#define ERRCODE_INVALID_ARGUMENT_FOR_NTILE \
  MAKE_SQLSTATE('2', '2', '0', '1', '4')
#define ERRCODE_INVALID_ARGUMENT_FOR_NTH_VALUE \
  MAKE_SQLSTATE('2', '2', '0', '1', '6')
#define ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION \
  MAKE_SQLSTATE('2', '2', '0', '1', 'F')
#define ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION \
  MAKE_SQLSTATE('2', '2', '0', '1', 'G')
#define ERRCODE_INVALID_CHARACTER_VALUE_FOR_CAST \
  MAKE_SQLSTATE('2', '2', '0', '1', '8')
#define ERRCODE_INVALID_DATETIME_FORMAT MAKE_SQLSTATE('2', '2', '0', '0', '7')
#define ERRCODE_INVALID_ESCAPE_CHARACTER MAKE_SQLSTATE('2', '2', '0', '1', '9')
#define ERRCODE_INVALID_ESCAPE_OCTET MAKE_SQLSTATE('2', '2', '0', '0', 'D')
#define ERRCODE_INVALID_ESCAPE_SEQUENCE MAKE_SQLSTATE('2', '2', '0', '2', '5')
#define ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER \
  MAKE_SQLSTATE('2', '2', 'P', '0', '6')
#define ERRCODE_INVALID_INDICATOR_PARAMETER_VALUE \
  MAKE_SQLSTATE('2', '2', '0', '1', '0')
#define ERRCODE_INVALID_PARAMETER_VALUE MAKE_SQLSTATE('2', '2', '0', '2', '3')
#define ERRCODE_INVALID_REGULAR_EXPRESSION \
  MAKE_SQLSTATE('2', '2', '0', '1', 'B')
#define ERRCODE_INVALID_ROW_COUNT_IN_LIMIT_CLAUSE \
  MAKE_SQLSTATE('2', '2', '0', '1', 'W')
#define ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE \
  MAKE_SQLSTATE('2', '2', '0', '1', 'X')
#define ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE \
  MAKE_SQLSTATE('2', '2', '0', '0', '9')
#define ERRCODE_INVALID_USE_OF_ESCAPE_CHARACTER \
  MAKE_SQLSTATE('2', '2', '0', '0', 'C')
#define ERRCODE_MOST_SPECIFIC_TYPE_MISMATCH \
  MAKE_SQLSTATE('2', '2', '0', '0', 'G')
#define ERRCODE_NULL_VALUE_NOT_ALLOWED MAKE_SQLSTATE('2', '2', '0', '0', '4')
#define ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER \
  MAKE_SQLSTATE('2', '2', '0', '0', '2')
#define ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE \
  MAKE_SQLSTATE('2', '2', '0', '0', '3')
#define ERRCODE_DOP_VALUE_OUT_OF_RANGE MAKE_SQLSTATE('2', '2', '0', '1', '7')
#define ERRCODE_STRING_DATA_LENGTH_MISMATCH \
  MAKE_SQLSTATE('2', '2', '0', '2', '6')
#define ERRCODE_REGEXP_MISMATCH MAKE_SQLSTATE('2', '2', '0', '2', '8')
#define ERRCODE_STRING_DATA_RIGHT_TRUNCATION \
  MAKE_SQLSTATE('2', '2', '0', '0', '1')
#define ERRCODE_SUBSTRING_ERROR MAKE_SQLSTATE('2', '2', '0', '1', '1')
#define ERRCODE_TRIM_ERROR MAKE_SQLSTATE('2', '2', '0', '2', '7')
#define ERRCODE_UNTERMINATED_C_STRING MAKE_SQLSTATE('2', '2', '0', '2', '4')
#define ERRCODE_ZERO_LENGTH_CHARACTER_STRING \
  MAKE_SQLSTATE('2', '2', '0', '0', 'F')
#define ERRCODE_FLOATING_POINT_EXCEPTION MAKE_SQLSTATE('2', '2', 'P', '0', '1')
#define ERRCODE_INVALID_TEXT_REPRESENTATION \
  MAKE_SQLSTATE('2', '2', 'P', '0', '2')
#define ERRCODE_INVALID_BINARY_REPRESENTATION \
  MAKE_SQLSTATE('2', '2', 'P', '0', '3')
#define ERRCODE_BAD_COPY_FILE_FORMAT MAKE_SQLSTATE('2', '2', 'P', '0', '4')
#define ERRCODE_UNTRANSLATABLE_CHARACTER MAKE_SQLSTATE('2', '2', 'P', '0', '5')
#define ERRCODE_NOT_AN_XML_DOCUMENT MAKE_SQLSTATE('2', '2', '0', '0', 'L')
#define ERRCODE_INVALID_XML_DOCUMENT MAKE_SQLSTATE('2', '2', '0', '0', 'M')
#define ERRCODE_INVALID_XML_CONTENT MAKE_SQLSTATE('2', '2', '0', '0', 'N')
#define ERRCODE_INVALID_XML_ERROR_CONTEXT MAKE_SQLSTATE('2', '2', '0', '0', 'O')
#define ERRCODE_INVALID_XML_COMMENT MAKE_SQLSTATE('2', '2', '0', '0', 'S')
#define ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION \
  MAKE_SQLSTATE('2', '2', '0', '0', 'T')

/* Class 23 - Integrity Constraint Violation
 */
#define ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION \
  MAKE_SQLSTATE('2', '3', '0', '0', '0')
#define ERRCODE_RESTRICT_VIOLATION MAKE_SQLSTATE('2', '3', '0', '0', '1')
#define ERRCODE_NOT_NULL_VIOLATION MAKE_SQLSTATE('2', '3', '5', '0', '2')
#define ERRCODE_FOREIGN_KEY_VIOLATION MAKE_SQLSTATE('2', '3', '5', '0', '3')
#define ERRCODE_UNIQUE_VIOLATION MAKE_SQLSTATE('2', '3', '5', '0', '5')
#define ERRCODE_CHECK_VIOLATION MAKE_SQLSTATE('2', '3', '5', '1', '4')
#define ERRCODE_EXCLUSION_VIOLATION MAKE_SQLSTATE('2', '3', 'P', '0', '1')

/* Class 24 - Invalid Cursor State
 */
#define ERRCODE_INVALID_CURSOR_STATE MAKE_SQLSTATE('2', '4', '0', '0', '0')

/* Class 25 - Invalid Transaction State
 */
#define ERRCODE_INVALID_TRANSACTION_STATE MAKE_SQLSTATE('2', '5', '0', '0', '0')
#define ERRCODE_ACTIVE_SQL_TRANSACTION MAKE_SQLSTATE('2', '5', '0', '0', '1')
#define ERRCODE_BRANCH_TRANSACTION_ALREADY_ACTIVE \
  MAKE_SQLSTATE('2', '5', '0', '0', '2')
#define ERRCODE_HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL \
  MAKE_SQLSTATE('2', '5', '0', '0', '8')
#define ERRCODE_INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION \
  MAKE_SQLSTATE('2', '5', '0', '0', '3')
#define ERRCODE_INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION \
  MAKE_SQLSTATE('2', '5', '0', '0', '4')
#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION \
  MAKE_SQLSTATE('2', '5', '0', '0', '5')
#define ERRCODE_READ_ONLY_SQL_TRANSACTION MAKE_SQLSTATE('2', '5', '0', '0', '6')
#define ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED \
  MAKE_SQLSTATE('2', '5', '0', '0', '7')
#define ERRCODE_RUN_TRANSACTION_DURING_RECOVERY \
  MAKE_SQLSTATE('2', '5', '0', '0', '9')
#define ERRCODE_GXID_DOES_NOT_EXIST MAKE_SQLSTATE('2', '5', '0', '1', '0')
#define ERRCODE_NO_ACTIVE_SQL_TRANSACTION MAKE_SQLSTATE('2', '5', 'P', '0', '1')
#define ERRCODE_IN_FAILED_SQL_TRANSACTION MAKE_SQLSTATE('2', '5', 'P', '0', '2')

/* Class 26 - Invalid SQL Statement Name
 */
#define ERRCODE_INVALID_SQL_STATEMENT_NAME \
  MAKE_SQLSTATE('2', '6', '0', '0', '0')
#define ERRCODE_SLOW_QUERY MAKE_SQLSTATE('2', '6', '0', '0', '1')
#define ERRCODE_ACTIVE_SESSION_PROFILE MAKE_SQLSTATE('2', '6', '0', '0', '2')

/* Class 27 - Triggered Data Change Violation
 */
#define ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION \
  MAKE_SQLSTATE('2', '7', '0', '0', '0')
#define ERRCODE_TRIGGERED_INVALID_TUPLE MAKE_SQLSTATE('2', '7', '0', '0', '1')

/* Class 28 - Invalid Authorization Specification
 */
#define ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION \
  MAKE_SQLSTATE('2', '8', '0', '0', '0')
#define ERRCODE_INVALID_PASSWORD MAKE_SQLSTATE('2', '8', 'P', '0', '1')
#define ERRCODE_INITIAL_PASSWORD_NOT_MODIFIED \
  MAKE_SQLSTATE('2', '8', 'P', '0', '2')

/* Class 29 - Invalid or Unexpected Status
 */
#define ERRCODE_INVALID_STATUS MAKE_SQLSTATE('2', '9', '0', '0', '0')
#define ERRCODE_INVALID_TABLESAMPLE_ARGUMENT \
  MAKE_SQLSTATE('2', '9', '0', '0', '1')
#define ERRCODE_INVALID_TABLESAMPLE_REPEAT \
  MAKE_SQLSTATE('2', '9', '0', '0', '2')
#define ERRORCODE_ASSERT_FAILED MAKE_SQLSTATE('2', '9', '0', '0', '3')
#define ERRCODE_CACHE_LOOKUP_FAILED MAKE_SQLSTATE('2', '9', 'P', '0', '1')
#define ERRCODE_FETCH_DATA_FAILED MAKE_SQLSTATE('2', '9', 'P', '0', '2')
#define ERRCODE_FLUSH_DATA_SIZE_MISMATCH MAKE_SQLSTATE('2', '9', 'P', '0', '3')
#define ERRCODE_RELATION_OPEN_ERROR MAKE_SQLSTATE('2', '9', 'P', '0', '4')
#define ERRCODE_RELATION_CLOSE_ERROR MAKE_SQLSTATE('2', '9', 'P', '0', '5')
#define ERRCODE_INVALID_CACHE_PLAN MAKE_SQLSTATE('2', '9', 'P', '0', '6')

/* Class 2B - Dependent Privilege Descriptors Still Exist
 */
#define ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST \
  MAKE_SQLSTATE('2', 'B', '0', '0', '0')
#define ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST \
  MAKE_SQLSTATE('2', 'B', 'P', '0', '1')

/* Class 2D - Invalid Transaction Termination
 */
#define ERRCODE_INVALID_TRANSACTION_TERMINATION \
  MAKE_SQLSTATE('2', 'D', '0', '0', '0')

/* Class 2F - SQL Routine Exception
 */
#define ERRCODE_SQL_ROUTINE_EXCEPTION MAKE_SQLSTATE('2', 'F', '0', '0', '0')
#define ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT \
  MAKE_SQLSTATE('2', 'F', '0', '0', '5')
#define ERRCODE_S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED \
  MAKE_SQLSTATE('2', 'F', '0', '0', '2')
#define ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED \
  MAKE_SQLSTATE('2', 'F', '0', '0', '3')
#define ERRCODE_S_R_E_READING_SQL_DATA_NOT_PERMITTED \
  MAKE_SQLSTATE('2', 'F', '0', '0', '4')

/* Class 34 - Invalid Cursor Name
 */
#define ERRCODE_INVALID_CURSOR_NAME MAKE_SQLSTATE('3', '4', '0', '0', '0')

/* Class 38 - External Routine Exception
 */
#define ERRCODE_EXTERNAL_ROUTINE_EXCEPTION \
  MAKE_SQLSTATE('3', '8', '0', '0', '0')
#define ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED \
  MAKE_SQLSTATE('3', '8', '0', '0', '1')
#define ERRCODE_E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED \
  MAKE_SQLSTATE('3', '8', '0', '0', '2')
#define ERRCODE_E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED \
  MAKE_SQLSTATE('3', '8', '0', '0', '3')
#define ERRCODE_E_R_E_READING_SQL_DATA_NOT_PERMITTED \
  MAKE_SQLSTATE('3', '8', '0', '0', '4')

/* Class 39 - External Routine Invocation Exception
 */
#define ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION \
  MAKE_SQLSTATE('3', '9', '0', '0', '0')
#define ERRCODE_E_R_I_E_INVALID_SQLSTATE_RETURNED \
  MAKE_SQLSTATE('3', '9', '0', '0', '1')
#define ERRCODE_E_R_I_E_NULL_VALUE_NOT_ALLOWED \
  MAKE_SQLSTATE('3', '9', '0', '0', '4')
#define ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED \
  MAKE_SQLSTATE('3', '9', 'P', '0', '1')
#define ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED \
  MAKE_SQLSTATE('3', '9', 'P', '0', '2')

/* Class 3B - Savepoint Exception
 */
#define ERRCODE_SAVEPOINT_EXCEPTION MAKE_SQLSTATE('3', 'B', '0', '0', '0')
#define ERRCODE_S_E_INVALID_SPECIFICATION MAKE_SQLSTATE('3', 'B', '0', '0', '1')

/* Class 3D - Invalid Catalog Name
 */
#define ERRCODE_INVALID_CATALOG_NAME MAKE_SQLSTATE('3', 'D', '0', '0', '0')

/* Class 3F - Invalid Schema Name
 */
#define ERRCODE_INVALID_SCHEMA_NAME MAKE_SQLSTATE('3', 'F', '0', '0', '0')

/* Class 40 - Transaction Rollback
 */
#define ERRCODE_TRANSACTION_ROLLBACK MAKE_SQLSTATE('4', '0', '0', '0', '0')
#define ERRCODE_T_R_INTEGRITY_CONSTRAINT_VIOLATION \
  MAKE_SQLSTATE('4', '0', '0', '0', '2')
#define ERRCODE_T_R_SERIALIZATION_FAILURE MAKE_SQLSTATE('4', '0', '0', '0', '1')
#define ERRCODE_T_R_STATEMENT_COMPLETION_UNKNOWN \
  MAKE_SQLSTATE('4', '0', '0', '0', '3')
#define ERRCODE_T_R_DEADLOCK_DETECTED MAKE_SQLSTATE('4', '0', 'P', '0', '1')

/* Class 42 - Syntax Error or Access Rule Violation
 */
#define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION \
  MAKE_SQLSTATE('4', '2', '0', '0', '0')
#define ERRCODE_SYNTAX_ERROR MAKE_SQLSTATE('4', '2', '6', '0', '1')
#define ERRCODE_INSUFFICIENT_PRIVILEGE MAKE_SQLSTATE('4', '2', '5', '0', '1')
#define ERRCODE_CANNOT_COERCE MAKE_SQLSTATE('4', '2', '8', '4', '6')
#define ERRCODE_GROUPING_ERROR MAKE_SQLSTATE('4', '2', '8', '0', '3')
#define ERRCODE_WINDOWING_ERROR MAKE_SQLSTATE('4', '2', 'P', '2', '0')
#define ERRCODE_INVALID_RECURSION MAKE_SQLSTATE('4', '2', 'P', '1', '9')
#define ERRCODE_INVALID_FOREIGN_KEY MAKE_SQLSTATE('4', '2', '8', '3', '0')
#define ERRCODE_INVALID_NAME MAKE_SQLSTATE('4', '2', '6', '0', '2')
#define ERRCODE_NAME_TOO_LONG MAKE_SQLSTATE('4', '2', '6', '2', '2')
#define ERRCODE_RESERVED_NAME MAKE_SQLSTATE('4', '2', '9', '3', '9')
#define ERRCODE_DATATYPE_MISMATCH MAKE_SQLSTATE('4', '2', '8', '0', '4')
#define ERRCODE_INDETERMINATE_DATATYPE MAKE_SQLSTATE('4', '2', 'P', '3', '8')
#define ERRCODE_COLLATION_MISMATCH MAKE_SQLSTATE('4', '2', 'P', '2', '1')
#define ERRCODE_INDETERMINATE_COLLATION MAKE_SQLSTATE('4', '2', 'P', '2', '2')
#define ERRCODE_WRONG_OBJECT_TYPE MAKE_SQLSTATE('4', '2', '8', '0', '9')
#define ERRCODE_PARTITION_ERROR MAKE_SQLSTATE('4', '2', 'P', '2', '3')
#define ERRCODE_INVALID_ATTRIBUTE MAKE_SQLSTATE('4', '2', 'P', '2', '4')
#define ERRCODE_INVALID_AGG MAKE_SQLSTATE('4', '2', 'P', '2', '5')
#define ERRCODE_RESOURCE_POOL_ERROR MAKE_SQLSTATE('4', '2', 'P', '2', '6')
#define ERRCODE_PLAN_PARENT_NOT_FOUND MAKE_SQLSTATE('4', '2', 'P', '2', '7')
#define ERRCODE_MODIFY_CONFLICTS MAKE_SQLSTATE('4', '2', 'P', '2', '8')
#define ERRCODE_DISTRIBUTION_ERROR MAKE_SQLSTATE('4', '2', 'P', '2', '9')
#define ERRCODE_UNDEFINED_COLUMN MAKE_SQLSTATE('4', '2', '7', '0', '3')
#define ERRCODE_UNDEFINED_CURSOR MAKE_SQLSTATE('3', '4', '0', '0', '1')
#define ERRCODE_UNDEFINED_DATABASE MAKE_SQLSTATE('3', 'D', '0', '0', '0')
#define ERRCODE_UNDEFINED_FUNCTION MAKE_SQLSTATE('4', '2', '8', '8', '3')
#define ERRCODE_UNDEFINED_PACKAGE MAKE_SQLSTATE('4', '2', '8', '8', '4')
#define ERRCODE_UNDEFINED_PSTATEMENT MAKE_SQLSTATE('2', '6', '0', '1', '0')
#define ERRCODE_UNDEFINED_SCHEMA MAKE_SQLSTATE('3', 'F', '0', '0', '1')
#define ERRCODE_UNDEFINED_TABLE MAKE_SQLSTATE('4', '2', 'P', '0', '1')
#define ERRCODE_UNDEFINED_PARAMETER MAKE_SQLSTATE('4', '2', 'P', '0', '2')
#define ERRCODE_UNDEFINED_OBJECT MAKE_SQLSTATE('4', '2', '7', '0', '4')
#define ERRCODE_DUPLICATE_COLUMN MAKE_SQLSTATE('4', '2', '7', '0', '1')
#define ERRCODE_DUPLICATE_CURSOR MAKE_SQLSTATE('4', '2', 'P', '0', '3')
#define ERRCODE_DUPLICATE_DATABASE MAKE_SQLSTATE('4', '2', 'P', '0', '4')
#define ERRCODE_DUPLICATE_FUNCTION MAKE_SQLSTATE('4', '2', '7', '2', '3')
#define ERRCODE_DUPLICATE_PACKAGE MAKE_SQLSTATE('4', '2', '7', '2', '4')
#define ERRCODE_DUPLICATE_PSTATEMENT MAKE_SQLSTATE('4', '2', 'P', '0', '5')
#define ERRCODE_DUPLICATE_SCHEMA MAKE_SQLSTATE('4', '2', 'P', '0', '6')
#define ERRCODE_DUPLICATE_TABLE MAKE_SQLSTATE('4', '2', 'P', '0', '7')
#define ERRCODE_DUPLICATE_ALIAS MAKE_SQLSTATE('4', '2', '7', '1', '2')
#define ERRCODE_DUPLICATE_OBJECT MAKE_SQLSTATE('4', '2', '7', '1', '0')
#define ERRCODE_AMBIGUOUS_COLUMN MAKE_SQLSTATE('4', '2', '7', '0', '2')
#define ERRCODE_AMBIGUOUS_FUNCTION MAKE_SQLSTATE('4', '2', '7', '2', '5')
#define ERRCODE_AMBIGUOUS_PARAMETER MAKE_SQLSTATE('4', '2', 'P', '0', '8')
#define ERRCODE_AMBIGUOUS_ALIAS MAKE_SQLSTATE('4', '2', 'P', '0', '9')
#define ERRCODE_INVALID_COLUMN_REFERENCE MAKE_SQLSTATE('4', '2', 'P', '1', '0')
#define ERRCODE_INVALID_COLUMN_DEFINITION MAKE_SQLSTATE('4', '2', '6', '1', '1')
#define ERRCODE_INVALID_CURSOR_DEFINITION MAKE_SQLSTATE('4', '2', 'P', '1', '1')
#define ERRCODE_INVALID_DATABASE_DEFINITION \
  MAKE_SQLSTATE('4', '2', 'P', '1', '2')
#define ERRCODE_INVALID_FUNCTION_DEFINITION \
  MAKE_SQLSTATE('4', '2', 'P', '1', '3')
#define ERRCODE_INVALID_PSTATEMENT_DEFINITION \
  MAKE_SQLSTATE('4', '2', 'P', '1', '4')
#define ERRCODE_INVALID_SCHEMA_DEFINITION MAKE_SQLSTATE('4', '2', 'P', '1', '5')
#define ERRCODE_INVALID_TABLE_DEFINITION MAKE_SQLSTATE('4', '2', 'P', '1', '6')
#define ERRCODE_INVALID_OBJECT_DEFINITION MAKE_SQLSTATE('4', '2', 'P', '1', '7')
#define ERRCODE_INVALID_TEMP_OBJECTS MAKE_SQLSTATE('4', '2', 'P', '1', '8')
#define ERRCODE_INVALID_PACKAGE_DEFINITION \
  MAKE_SQLSTATE('4', '2', 'P', '6', '5')
#define ERRCODE_UNDEFINED_KEY MAKE_SQLSTATE('4', '2', '7', '0', '5')
#define ERRCODE_DUPLICATE_KEY MAKE_SQLSTATE('4', '2', '7', '1', '1')
#define ERRCODE_UNDEFINED_CL_COLUMN MAKE_SQLSTATE('4', '2', '7', '1', '3')

/* Class 44 - WITH CHECK OPTION Violation
 */
#define ERRCODE_WITH_CHECK_OPTION_VIOLATION \
  MAKE_SQLSTATE('4', '4', '0', '0', '0')

/* Class 53 - Insufficient Resources
 */
#define ERRCODE_INSUFFICIENT_RESOURCES MAKE_SQLSTATE('5', '3', '0', '0', '0')
#define ERRCODE_DISK_FULL MAKE_SQLSTATE('5', '3', '1', '0', '0')
#define ERRCODE_OUT_OF_MEMORY MAKE_SQLSTATE('5', '3', '2', '0', '0')
#define ERRCODE_TOO_MANY_CONNECTIONS MAKE_SQLSTATE('5', '3', '3', '0', '0')
#define ERRCODE_CONFIGURATION_LIMIT_EXCEEDED \
  MAKE_SQLSTATE('5', '3', '4', '0', '0')
#define ERRCODE_OUT_OF_BUFFER MAKE_SQLSTATE('5', '3', '5', '0', '0')

/* Class 54 - Program Limit Exceeded
 */
#define ERRCODE_PROGRAM_LIMIT_EXCEEDED MAKE_SQLSTATE('5', '4', '0', '0', '0')
#define ERRCODE_STATEMENT_TOO_COMPLEX MAKE_SQLSTATE('5', '4', '0', '0', '1')
#define ERRCODE_TOO_MANY_COLUMNS MAKE_SQLSTATE('5', '4', '0', '1', '1')
#define ERRCODE_TOO_MANY_ARGUMENTS MAKE_SQLSTATE('5', '4', '0', '2', '3')

/* Class 55 - Object Not In Prerequisite State
 */
#define ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE \
  MAKE_SQLSTATE('5', '5', '0', '0', '0')
#define ERRCODE_OBJECT_IN_USE MAKE_SQLSTATE('5', '5', '0', '0', '6')
#define ERRCODE_CANT_CHANGE_RUNTIME_PARAM MAKE_SQLSTATE('5', '5', 'P', '0', '2')
#define ERRCODE_LOCK_NOT_AVAILABLE MAKE_SQLSTATE('5', '5', 'P', '0', '3')

/* Class 57 - Operator Intervention
 */
#define ERRCODE_OPERATOR_INTERVENTION MAKE_SQLSTATE('5', '7', '0', '0', '0')
#define ERRCODE_QUERY_CANCELED MAKE_SQLSTATE('5', '7', '0', '1', '4')
#define ERRCODE_QUERY_INTERNAL_CANCEL MAKE_SQLSTATE('5', '7', '0', '1', '5')
#define ERRCODE_ADMIN_SHUTDOWN MAKE_SQLSTATE('5', '7', 'P', '0', '1')
#define ERRCODE_CRASH_SHUTDOWN MAKE_SQLSTATE('5', '7', 'P', '0', '2')
#define ERRCODE_CANNOT_CONNECT_NOW MAKE_SQLSTATE('5', '7', 'P', '0', '3')
#define ERRCODE_DATABASE_DROPPED MAKE_SQLSTATE('5', '7', 'P', '0', '4')
#define ERRCODE_RU_STOP_QUERY MAKE_SQLSTATE('5', '7', 'P', '0', '5')

/* Class 58 - System Error (errors external to PostgreSQL itself)
 */
#define ERRCODE_SYSTEM_ERROR MAKE_SQLSTATE('5', '8', '0', '0', '0')
#define ERRCODE_IO_ERROR MAKE_SQLSTATE('5', '8', '0', '3', '0')
#define ERRCODE_UNDEFINED_FILE MAKE_SQLSTATE('5', '8', 'P', '0', '1')
#define ERRCODE_DUPLICATE_FILE MAKE_SQLSTATE('5', '8', 'P', '0', '2')
#define ERRCODE_FILE_READ_FAILED MAKE_SQLSTATE('5', '8', 'P', '0', '3')
#define ERRCODE_FILE_WRITE_FAILED MAKE_SQLSTATE('5', '8', 'P', '0', '4')
#define ERRCODE_INVALID_ENCRYPTED_COLUMN_DATA \
  MAKE_SQLSTATE('2', '2', '0', '0', 'Z')

/* Class 59 - Recycle Object Operation Error
 */
#define ERRCODE_RBIN_LOCK_NOT_AVAILABLE MAKE_SQLSTATE('5', '9', '0', '0', '0')
#define ERRCODE_RBIN_UNDEFINED_OBJECT MAKE_SQLSTATE('5', '9', '0', '0', '1')

/* Class F0 - Configuration File Error
 */
#define ERRCODE_CONFIG_FILE_ERROR MAKE_SQLSTATE('F', '0', '0', '0', '0')
#define ERRCODE_LOCK_FILE_EXISTS MAKE_SQLSTATE('F', '0', '0', '0', '1')

/* Class HV - Foreign Data Wrapper Error (SQL/MED)
 */
#define ERRCODE_FDW_ERROR MAKE_SQLSTATE('H', 'V', '0', '0', '0')
#define ERRCODE_FDW_COLUMN_NAME_NOT_FOUND MAKE_SQLSTATE('H', 'V', '0', '0', '5')
#define ERRCODE_FDW_DYNAMIC_PARAMETER_VALUE_NEEDED \
  MAKE_SQLSTATE('H', 'V', '0', '0', '2')
#define ERRCODE_FDW_FUNCTION_SEQUENCE_ERROR \
  MAKE_SQLSTATE('H', 'V', '0', '1', '0')
#define ERRCODE_FDW_INCONSISTENT_DESCRIPTOR_INFORMATION \
  MAKE_SQLSTATE('H', 'V', '0', '2', '1')
#define ERRCODE_FDW_INVALID_ATTRIBUTE_VALUE \
  MAKE_SQLSTATE('H', 'V', '0', '2', '4')
#define ERRCODE_FDW_INVALID_COLUMN_NAME MAKE_SQLSTATE('H', 'V', '0', '0', '7')
#define ERRCODE_FDW_INVALID_COLUMN_NUMBER MAKE_SQLSTATE('H', 'V', '0', '0', '8')
#define ERRCODE_FDW_INVALID_DATA_TYPE MAKE_SQLSTATE('H', 'V', '0', '0', '4')
#define ERRCODE_FDW_INVALID_DATA_TYPE_DESCRIPTORS \
  MAKE_SQLSTATE('H', 'V', '0', '0', '6')
#define ERRCODE_FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER \
  MAKE_SQLSTATE('H', 'V', '0', '9', '1')
#define ERRCODE_FDW_INVALID_HANDLE MAKE_SQLSTATE('H', 'V', '0', '0', 'B')
#define ERRCODE_FDW_INVALID_OPTION_INDEX MAKE_SQLSTATE('H', 'V', '0', '0', 'C')
#define ERRCODE_FDW_INVALID_OPTION_NAME MAKE_SQLSTATE('H', 'V', '0', '0', 'D')
#define ERRCODE_FDW_INVALID_OPTION_DATA MAKE_SQLSTATE('H', 'V', '0', '0', 'E')
#define ERRCODE_FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH \
  MAKE_SQLSTATE('H', 'V', '0', '9', '0')
#define ERRCODE_FDW_INVALID_STRING_FORMAT MAKE_SQLSTATE('H', 'V', '0', '0', 'A')
#define ERRCODE_FDW_INVALID_USE_OF_NULL_POINTER \
  MAKE_SQLSTATE('H', 'V', '0', '0', '9')
#define ERRCODE_FDW_TOO_MANY_HANDLES MAKE_SQLSTATE('H', 'V', '0', '1', '4')
#define ERRCODE_FDW_OUT_OF_MEMORY MAKE_SQLSTATE('H', 'V', '0', '0', '1')
#define ERRCODE_FDW_NO_SCHEMAS MAKE_SQLSTATE('H', 'V', '0', '0', 'P')
#define ERRCODE_FDW_OPTION_NAME_NOT_FOUND MAKE_SQLSTATE('H', 'V', '0', '0', 'J')
#define ERRCODE_FDW_REPLY_HANDLE MAKE_SQLSTATE('H', 'V', '0', '0', 'K')
#define ERRCODE_FDW_SCHEMA_NOT_FOUND MAKE_SQLSTATE('H', 'V', '0', '0', 'Q')
#define ERRCODE_FDW_TABLE_NOT_FOUND MAKE_SQLSTATE('H', 'V', '0', '0', 'R')
#define ERRCODE_FDW_UNABLE_TO_CREATE_EXECUTION \
  MAKE_SQLSTATE('H', 'V', '0', '0', 'L')
#define ERRCODE_FDW_UNABLE_TO_CREATE_REPLY \
  MAKE_SQLSTATE('H', 'V', '0', '0', 'M')
#define ERRCODE_FDW_UNABLE_TO_ESTABLISH_CONNECTION \
  MAKE_SQLSTATE('H', 'V', '0', '0', 'N')
#define ERRCODE_FDW_INVALID_LIST_LENGTH MAKE_SQLSTATE('H', 'V', '0', '0', 'O')
#define ERRCODE_FDW_INVALID_SERVER_TYPE MAKE_SQLSTATE('H', 'V', '0', '0', 'S')
#define ERRCODE_FDW_OPERATION_NOT_SUPPORTED \
  MAKE_SQLSTATE('H', 'V', '0', '2', '5')
#define ERRCODE_FDW_CROSS_STORAGE_ENGINE_TRANSACTION_NOT_SUPPORTED \
  MAKE_SQLSTATE('H', 'V', '0', '2', '6')
#define ERRCODE_FDW_CROSS_STORAGE_ENGINE_QUERY_NOT_SUPPORTED \
  MAKE_SQLSTATE('H', 'V', '0', '2', '7')
#define ERRCODE_FDW_UPDATE_INDEXED_FIELD_NOT_SUPPORTED \
  MAKE_SQLSTATE('H', 'V', '0', '2', '8')
#define ERRCODE_FDW_TOO_MANY_INDEXES MAKE_SQLSTATE('H', 'V', '0', '2', '9')
#define ERRCODE_FDW_KEY_SIZE_EXCEEDS_MAX_ALLOWED \
  MAKE_SQLSTATE('H', 'V', '0', '3', '0')
#define ERRCODE_FDW_DDL_IN_TRANSACTION_NOT_ALLOWED \
  MAKE_SQLSTATE('H', 'V', '0', '3', '1')
#define ERRCODE_FDW_TOO_MANY_INDEX_COLUMNS \
  MAKE_SQLSTATE('H', 'V', '0', '3', '2')
#define ERRCODE_FDW_INDEX_ON_NULLABLE_COLUMN_NOT_ALLOWED \
  MAKE_SQLSTATE('H', 'V', '0', '3', '3')
#define ERRCODE_FDW_TOO_MANY_DDL_CHANGES_IN_TRANSACTION_NOT_ALLOWED \
  MAKE_SQLSTATE('H', 'V', '0', '3', '4')

/* Class P0 - PL/pgSQL Error
 */
#define ERRCODE_PLPGSQL_ERROR MAKE_SQLSTATE('P', '0', '0', '0', '0')
#define ERRCODE_RAISE_EXCEPTION MAKE_SQLSTATE('P', '0', '0', '0', '1')
#define ERRCODE_NO_DATA_FOUND MAKE_SQLSTATE('P', '0', '0', '0', '2')
#define ERRCODE_TOO_MANY_ROWS MAKE_SQLSTATE('P', '0', '0', '0', '3')
#define ERRCODE_FORALL_NEED_DML MAKE_SQLSTATE('P', '0', '0', '0', '4')

/* Class XX - Internal Error
 */
#define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X', 'X', '0', '0', '0')
#define ERRCODE_DATA_CORRUPTED MAKE_SQLSTATE('X', 'X', '0', '0', '1')
#define ERRCODE_INDEX_CORRUPTED MAKE_SQLSTATE('X', 'X', '0', '0', '2')
#define ERRCODE_STREAM_REMOTE_CLOSE_SOCKET \
  MAKE_SQLSTATE('X', 'X', '0', '0', '3')
#define ERRCODE_UNRECOGNIZED_NODE_TYPE MAKE_SQLSTATE('X', 'X', '0', '0', '4')
#define ERRCODE_UNEXPECTED_NULL_VALUE MAKE_SQLSTATE('X', 'X', '0', '0', '5')
#define ERRCODE_UNEXPECTED_NODE_STATE MAKE_SQLSTATE('X', 'X', '0', '0', '6')
#define ERRCODE_NULL_JUNK_ATTRIBUTE MAKE_SQLSTATE('X', 'X', '0', '0', '7')
#define ERRCODE_OPTIMIZER_INCONSISTENT_STATE \
  MAKE_SQLSTATE('X', 'X', '0', '0', '8')
#define ERRCODE_STREAM_DUPLICATE_QUERY_ID MAKE_SQLSTATE('X', 'X', '0', '0', '9')
#define ERRCODE_INVALID_BUFFER MAKE_SQLSTATE('X', 'X', '0', '1', '0')
#define ERRCODE_INVALID_BUFFER_REFERENCE MAKE_SQLSTATE('X', 'X', '0', '1', '1')
#define ERRCODE_NODE_ID_MISSMATCH MAKE_SQLSTATE('X', 'X', '0', '1', '2')
#define ERRCODE_CANNOT_MODIFY_XIDBASE MAKE_SQLSTATE('X', 'X', '0', '1', '3')
#define ERRCODE_UNEXPECTED_CHUNK_VALUE MAKE_SQLSTATE('X', 'X', '0', '1', '4')
#define ERRCODE_CN_RETRY_STUB MAKE_SQLSTATE('X', 'X', '0', '1', '5')

/* Class CG - CodeGen Error
 */
#define ERRCODE_CODEGEN_ERROR MAKE_SQLSTATE('C', 'G', '0', '0', '0')
#define ERRCODE_LOAD_IR_FUNCTION_FAILED MAKE_SQLSTATE('C', 'G', '0', '0', '1')
#define ERRCODE_LOAD_INTRINSIC_FUNCTION_FAILED \
  MAKE_SQLSTATE('C', 'G', '0', '0', '2')

/* Class YY - SQL Retry Error
 */
#define ERRCODE_CONNECTION_RESET_BY_PEER MAKE_SQLSTATE('Y', 'Y', '0', '0', '1')
#define ERRCODE_STREAM_CONNECTION_RESET_BY_PEER \
  MAKE_SQLSTATE('Y', 'Y', '0', '0', '2')
#define ERRCODE_LOCK_WAIT_TIMEOUT MAKE_SQLSTATE('Y', 'Y', '0', '0', '3')
#define ERRCODE_CONNECTION_TIMED_OUT MAKE_SQLSTATE('Y', 'Y', '0', '0', '4')
#define ERRCODE_SET_QUERY MAKE_SQLSTATE('Y', 'Y', '0', '0', '5')
#define ERRCODE_OUT_OF_LOGICAL_MEMORY MAKE_SQLSTATE('Y', 'Y', '0', '0', '6')
#define ERRCODE_SCTP_MEMORY_ALLOC MAKE_SQLSTATE('Y', 'Y', '0', '0', '7')
#define ERRCODE_SCTP_NO_DATA_IN_BUFFER MAKE_SQLSTATE('Y', 'Y', '0', '0', '8')
#define ERRCODE_SCTP_RELEASE_MEMORY_CLOSE MAKE_SQLSTATE('Y', 'Y', '0', '0', '9')
#define ERRCODE_SCTP_TCP_DISCONNECT MAKE_SQLSTATE('Y', 'Y', '0', '1', '0')
#define ERRCODE_SCTP_DISCONNECT MAKE_SQLSTATE('Y', 'Y', '0', '1', '1')
#define ERRCODE_SCTP_REMOTE_CLOSE MAKE_SQLSTATE('Y', 'Y', '0', '1', '2')
#define ERRCODE_SCTP_WAIT_POLL_UNKNOW MAKE_SQLSTATE('Y', 'Y', '0', '1', '3')
#define ERRCODE_SNAPSHOT_INVALID MAKE_SQLSTATE('Y', 'Y', '0', '1', '4')
#define ERRCODE_CONNECTION_RECEIVE_WRONG MAKE_SQLSTATE('Y', 'Y', '0', '1', '5')
#define ERRCODE_STREAM_CONCURRENT_UPDATE MAKE_SQLSTATE('Y', 'Y', '0', '1', '6')

/* Class SI - SPI Interface Error
 */
#define ERRCODE_SPI_ERROR MAKE_SQLSTATE('S', 'P', '0', '0', '0')
#define ERRCODE_SPI_CONNECTION_FAILURE MAKE_SQLSTATE('S', 'P', '0', '0', '1')
#define ERRCODE_SPI_FINISH_FAILURE MAKE_SQLSTATE('S', 'P', '0', '0', '2')
#define ERRCODE_SPI_PREPARE_FAILURE MAKE_SQLSTATE('S', 'P', '0', '0', '3')
#define ERRCODE_SPI_CURSOR_OPEN_FAILURE MAKE_SQLSTATE('S', 'P', '0', '0', '4')
#define ERRCODE_SPI_EXECUTE_FAILURE MAKE_SQLSTATE('S', 'P', '0', '0', '5')
#define ERRORCODE_SPI_IMPROPER_CALL MAKE_SQLSTATE('S', 'P', '0', '0', '6')
#define ERRCODE_PLDEBUGGER_ERROR MAKE_SQLSTATE('D', '0', '0', '0', '0')
#define ERRCODE_DUPLICATE_BREAKPOINT MAKE_SQLSTATE('D', '0', '0', '0', '1')
#define ERRCODE_FUNCTION_HASH_NOT_INITED MAKE_SQLSTATE('D', '0', '0', '0', '2')
#define ERRCODE_BREAKPOINT_NOT_PRESENT MAKE_SQLSTATE('D', '0', '0', '0', '3')
#define ERRCODE_TARGET_SERVER_ALREADY_ATTACHED \
  MAKE_SQLSTATE('D', '0', '0', '0', '4')
#define ERRCODE_TARGET_SERVER_NOT_ATTACHED \
  MAKE_SQLSTATE('D', '0', '0', '0', '5')
#define ERRCODE_DEBUG_SERVER_ALREADY_SYNC MAKE_SQLSTATE('D', '0', '0', '0', '6')
#define ERRCODE_DEBUG_TARGET_SERVERS_NOT_IN_SYNC \
  MAKE_SQLSTATE('D', '0', '0', '0', '7')
#define ERRCODE_TARGET_SERVER_ALREADY_SYNC \
  MAKE_SQLSTATE('D', '0', '0', '0', '8')
#define ERRCODE_NONEXISTANT_VARIABLE MAKE_SQLSTATE('D', '0', '0', '0', '9')
#define ERRCODE_INVALID_TARGET_SESSION_ID MAKE_SQLSTATE('D', '0', '0', '1', '0')
#define ERRCODE_INVALID_OPERATION MAKE_SQLSTATE('D', '0', '0', '1', '1')
#define ERRCODE_MAX_DEBUG_SESSIONS_REACHED \
  MAKE_SQLSTATE('D', '0', '0', '1', '2')
#define ERRCODE_MAX_BREAKPOINTS_REACHED MAKE_SQLSTATE('D', '0', '0', '1', '3')
#define ERRCODE_INITIALIZE_FAILED MAKE_SQLSTATE('D', '0', '0', '1', '4')
#define ERRCODE_PLDEBUGGER_TIMEOUT MAKE_SQLSTATE('D', '0', '0', '1', '5')
#define ERRCODE_FORALL_DML_ERROR MAKE_SQLSTATE('D', '0', '0', '1', '6')
#define ERRCODE_RBTREE_INVALID_NODE_STATE MAKE_SQLSTATE('R', 'B', '0', '0', '1')
#define ERRCODE_RBTREE_INVALID_ITERATOR_ORDER \
  MAKE_SQLSTATE('R', 'B', '0', '0', '2')
#define ERRCODE_DEBUG MAKE_SQLSTATE('D', 'B', '0', '0', '1')
#define ERRCODE_LOG MAKE_SQLSTATE('D', 'B', '0', '1', '0')
#define ERRCODE_OPERATE_FAILED MAKE_SQLSTATE('O', 'P', '0', '0', '1')
#define ERRCODE_OPERATE_RESULT_NOT_EXPECTED \
  MAKE_SQLSTATE('O', 'P', '0', '0', '2')
#define ERRCODE_OPERATE_NOT_SUPPORTED MAKE_SQLSTATE('O', 'P', '0', '0', '3')
#define ERRCODE_OPERATE_INVALID_PARAM MAKE_SQLSTATE('O', 'P', '0', 'A', '3')
#define ERRCODE_INDEX_OPERATOR_MISMATCH MAKE_SQLSTATE('O', 'P', '0', '0', '4')
#define ERRCODE_NO_FUNCTION_PROVIDED MAKE_SQLSTATE('O', 'P', '0', '0', '5')
#define ERRCODE_LOGICAL_DECODE_ERROR MAKE_SQLSTATE('L', 'L', '0', '0', '1')
#define ERRCODE_RELFILENODEMAP MAKE_SQLSTATE('L', 'L', '0', '0', '2')

/* Class TS - Timeseries Error
 */
#define ERRCODE_TS_COMMON_ERROR MAKE_SQLSTATE('T', 'S', '0', '0', '0')
#define ERRCODE_TS_KEYTYPE_MISMATCH MAKE_SQLSTATE('T', 'S', '0', '0', '1')

/* Class SE - Security Error
 */
#define ERRCODE_DUPLICATE_POLICY MAKE_SQLSTATE('4', '2', '7', '1', '4')
#define ERRCODE_DUPLICATE_LABEL MAKE_SQLSTATE('4', '2', '7', '1', '5')
#define ERRCODE_INVALID_AUDIT_LOG MAKE_SQLSTATE('S', 'E', '0', '0', '1')
